package com.kingdee.eas.custom.hostelmgr.hostelrating.app;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.hostelmgr.hostelrating.HostelRatingInfo;
import com.kingdee.eas.hr.base.CodingRuleManageFacadeFactory;

public class HostelRatingControllerBean extends
		AbstractHostelRatingControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hostelmgr.hostelrating.app.HostelRatingControllerBean");

	protected void setNumberFromCodingRule(Context ctx, IObjectValue model)
			throws BOSException, EASBizException {
		String number = CodingRuleManageFacadeFactory.getLocalInstance(ctx)
				.getNumberFromCodingRule(model, null, null);
		if (number == null)
			return;
		((HostelRatingInfo) model).setNumber(number);
	}

	@Override
	protected void _addnew(Context ctx, IObjectPK pk, IObjectValue model)
			throws BOSException, EASBizException {
		this.setNumberFromCodingRule(ctx, model);
		super._addnew(ctx, pk, model);
	}

	@Override
	protected IObjectPK _addnew(Context ctx, IObjectValue model)
			throws BOSException, EASBizException {
		this.setNumberFromCodingRule(ctx, model);
		return super._addnew(ctx, model);
	}
}